#include <asm.h>
#include <regdef.h>
#include <inst_test.h>

LEAF(n40_mflo_test)
    .set noreorder
    addiu s0, s0 ,1
    li  s2, 0x0
###test inst
    TEST_MFLO(0x08fc0000, 0x08fc0000)
    TEST_MFLO(0xc021e948, 0xc021e948)
    TEST_MFLO(0xeff0883e, 0xeff0883e)
    TEST_MFLO(0x8d1c588c, 0x8d1c588c)
    TEST_MFLO(0x04eba480, 0x04eba480)
    TEST_MFLO(0x4f6ceec0, 0x4f6ceec0)
    TEST_MFLO(0xbfc9f610, 0xbfc9f610)
    TEST_MFLO(0xa1b59045, 0xa1b59045)
    TEST_MFLO(0x94991e58, 0x94991e58)
    TEST_MFLO(0x17523780, 0x17523780)
    TEST_MFLO(0xae6c87b5, 0xae6c87b5)
    TEST_MFLO(0xd100fad4, 0xd100fad4)
    TEST_MFLO(0x9b90bc1a, 0x9b90bc1a)
    TEST_MFLO(0xa31b0900, 0xa31b0900)
    TEST_MFLO(0xf96fee06, 0xf96fee06)
    TEST_MFLO(0x39b6da7c, 0x39b6da7c)
    TEST_MFLO(0x1e4af85a, 0x1e4af85a)
    TEST_MFLO(0x2ef1759b, 0x2ef1759b)
    TEST_MFLO(0x4e9b9200, 0x4e9b9200)
    TEST_MFLO(0x9b130250, 0x9b130250)
    TEST_MFLO(0xdcee01c8, 0xdcee01c8)
    TEST_MFLO(0x4eb32d84, 0x4eb32d84)
    TEST_MFLO(0x57a00240, 0x57a00240)
    TEST_MFLO(0xdbcd8ea4, 0xdbcd8ea4)
    TEST_MFLO(0x6a50c5a8, 0x6a50c5a8)
    TEST_MFLO(0xd4699cd9, 0xd4699cd9)
    TEST_MFLO(0x89c4604e, 0x89c4604e)
    TEST_MFLO(0x43855984, 0x43855984)
    TEST_MFLO(0x2134659c, 0x2134659c)
    TEST_MFLO(0xd0b1a0a0, 0xd0b1a0a0)
    TEST_MFLO(0x164d0d80, 0x164d0d80)
    TEST_MFLO(0xb2ec642c, 0xb2ec642c)
    TEST_MFLO(0x40d02caa, 0x40d02caa)
    TEST_MFLO(0x713e3840, 0x713e3840)
    TEST_MFLO(0x2a02c9ff, 0x2a02c9ff)
    TEST_MFLO(0x2366722b, 0x2366722b)
    TEST_MFLO(0xad993150, 0xad993150)
    TEST_MFLO(0x6568c99e, 0x6568c99e)
    TEST_MFLO(0xf17a1170, 0xf17a1170)
    TEST_MFLO(0xa33641a9, 0xa33641a9)
    TEST_MFLO(0x99ab21a0, 0x99ab21a0)
    TEST_MFLO(0x8611118c, 0x8611118c)
    TEST_MFLO(0x09e8f575, 0x09e8f575)
    TEST_MFLO(0xf43f40ae, 0xf43f40ae)
    TEST_MFLO(0x397a1bb9, 0x397a1bb9)
    TEST_MFLO(0x171e590c, 0x171e590c)
    TEST_MFLO(0x6c387e12, 0x6c387e12)
    TEST_MFLO(0x09becd5f, 0x09becd5f)
    TEST_MFLO(0x73e07a20, 0x73e07a20)
    TEST_MFLO(0xd2d64d50, 0xd2d64d50)
    TEST_MFLO(0xcae4b160, 0xcae4b160)
    TEST_MFLO(0x46d45ca8, 0x46d45ca8)
    TEST_MFLO(0x3c843dce, 0x3c843dce)
    TEST_MFLO(0x90d1a267, 0x90d1a267)
    TEST_MFLO(0x129d4a7e, 0x129d4a7e)
    TEST_MFLO(0xfccdb42e, 0xfccdb42e)
    TEST_MFLO(0xd7059700, 0xd7059700)
    TEST_MFLO(0x0a4b664c, 0x0a4b664c)
    TEST_MFLO(0xabedfcc0, 0xabedfcc0)
    TEST_MFLO(0x04f09b68, 0x04f09b68)
    TEST_MFLO(0xb7261aa0, 0xb7261aa0)
    TEST_MFLO(0xb2aed1e0, 0xb2aed1e0)
    TEST_MFLO(0x725bf330, 0x725bf330)
    TEST_MFLO(0xa2ed62c4, 0xa2ed62c4)
    TEST_MFLO(0x39bb041e, 0x39bb041e)
    TEST_MFLO(0x076f516a, 0x076f516a)
    TEST_MFLO(0x477124e0, 0x477124e0)
    TEST_MFLO(0xaa6a9390, 0xaa6a9390)
    TEST_MFLO(0xcce63c0c, 0xcce63c0c)
    TEST_MFLO(0x1dc7b89c, 0x1dc7b89c)
    TEST_MFLO(0x3c3950e0, 0x3c3950e0)
    TEST_MFLO(0xae4926a2, 0xae4926a2)
    TEST_MFLO(0xe0917420, 0xe0917420)
    TEST_MFLO(0xa36e6448, 0xa36e6448)
    TEST_MFLO(0xdf56da8b, 0xdf56da8b)
    TEST_MFLO(0xacedeffc, 0xacedeffc)
    TEST_MFLO(0x771bfc28, 0x771bfc28)
    TEST_MFLO(0x418ef953, 0x418ef953)
    TEST_MFLO(0xaf65ef96, 0xaf65ef96)
    TEST_MFLO(0xe739d10c, 0xe739d10c)
    TEST_MFLO(0x17b0f8d4, 0x17b0f8d4)
    TEST_MFLO(0xda947912, 0xda947912)
    TEST_MFLO(0x2c1bd684, 0x2c1bd684)
    TEST_MFLO(0xda0f792c, 0xda0f792c)
    TEST_MFLO(0x465d56f8, 0x465d56f8)
    TEST_MFLO(0x1f06c400, 0x1f06c400)
    TEST_MFLO(0xaba4647f, 0xaba4647f)
    TEST_MFLO(0x9a035369, 0x9a035369)
    TEST_MFLO(0xbe933612, 0xbe933612)
    TEST_MFLO(0xc479087c, 0xc479087c)
    TEST_MFLO(0x82f518c8, 0x82f518c8)
    TEST_MFLO(0x263c4f70, 0x263c4f70)
    TEST_MFLO(0xa5e08312, 0xa5e08312)
    TEST_MFLO(0x0c5d3937, 0x0c5d3937)
    TEST_MFLO(0xd4defa00, 0xd4defa00)
    TEST_MFLO(0x8eaeb5be, 0x8eaeb5be)
    TEST_MFLO(0xf5154cd0, 0xf5154cd0)
    TEST_MFLO(0xc0e5f104, 0xc0e5f104)
    TEST_MFLO(0x45ba9b88, 0x45ba9b88)
    TEST_MFLO(0x0c6f4b7d, 0x0c6f4b7d)
    TEST_MFLO(0x84d2ee9d, 0x84d2ee9d)
    TEST_MFLO(0x0b8cca60, 0x0b8cca60)
    TEST_MFLO(0x34177838, 0x34177838)
    TEST_MFLO(0xd497762d, 0xd497762d)
    TEST_MFLO(0xa9d9686c, 0xa9d9686c)
    TEST_MFLO(0x70e58844, 0x70e58844)
    TEST_MFLO(0xa35963da, 0xa35963da)
    TEST_MFLO(0xd596c72c, 0xd596c72c)
    TEST_MFLO(0x6d90cae6, 0x6d90cae6)
    TEST_MFLO(0xaecd04a4, 0xaecd04a4)
    TEST_MFLO(0xd0db39f8, 0xd0db39f8)
    TEST_MFLO(0x2751a62f, 0x2751a62f)
    TEST_MFLO(0x77597560, 0x77597560)
    TEST_MFLO(0x7a82fb9e, 0x7a82fb9e)
    TEST_MFLO(0x00000000, 0x00000000)
###detect exception
    bne s2, zero, inst_error
    nop
###score ++
    addiu s3, s3, 1
###output (s0<<24)|s3
inst_error:  
    sll t1, s0, 24
    or t0, t1, s3 
    sw t0, 0(s1)
    jr ra
    nop
END(n40_mflo_test)
